package com.jin.spirng_boot_learn.controllers;

import com.jin.spirng_boot_learn.constant.Response;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@RestController
@Slf4j
public class HelloController {

    @GetMapping("/hello")
    public @ResponseBody String hello() {
        System.out.println("222222222222222222222222222222222222222222");
        return "hello world";
    }

     @PostMapping("/session")
    public @ResponseBody
     Response getWebInfo(@CookieValue("JSESSIONID") String cookies,
                         @RequestHeader("Accept-Encoding") String encoding) {

        return Response.ok;
    }

    // todo 有问题不能访问
    @GetMapping("/optional")
    public @ResponseBody Response optional(@RequestParam("name") Optional<String> name) {
        System.out.println(name.orElse("no name"));
        return Response.ok;
    }


}
